const mongoose = require('mongoose')

mongoose.connect('mongodb://localhost:27017/adv',{useNewUrlParser: true})

// 连接成功
mongoose.connection.on('connected', () => {
  console.log('[SUCCESS] Mongoose connection successfully')
})

// 连接异常
mongoose.connection.on('error', (err) => {
  console.log('[ERROR] Mongoose connection error ' + err)
})

// 连接断开
mongoose.connection.on('disconnected', () => {
  console.log('[DISCONNECTED] Mongoose connection disconnected')
})

module.exports = mongoose
